package jp.aztech.android.kawasakiwelfare;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * デバック情報を表示する Activity
 */
public class InfoActivity extends Activity {
	private final static String TAG  = "InfoActivity";

    /* 改行コード */
	private final static String LF = "\n";

    /* ビュー */
	private LinearLayout mLinearLayoutMain;
	private TextView mTextViewInfo1;
	private TextView mTextViewInfo2;

    /* 画面密度 */
	private float density = 0;
	
	/**
	 * === onCreate ===
	 */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // タイトルバーを非表示に        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        setContentView(R.layout.info);

		// 画面サイズを取得する
 		WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
 		Display display = wm.getDefaultDisplay();

		// ディスプレイの情報を取得する 		
 		DisplayMetrics metrics = new DisplayMetrics();  
 		getWindowManager().getDefaultDisplay().getMetrics(metrics);

 		density = metrics.density;
 		
  		// ビューを取得する 
    	mLinearLayoutMain = (LinearLayout) findViewById(R.id.linearlayout_main);
        mTextViewInfo1 = (TextView) findViewById(R.id.textview_info1);
        mTextViewInfo2 = (TextView) findViewById(R.id.textview_info2);
                 
        mTextViewInfo1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // タッチしたときに、表示する
            	int wp = mLinearLayoutMain.getWidth();
            	int hp = mLinearLayoutMain.getHeight();
            	int wd = (int)( wp / density );
            	int hd = (int)( hp / density );
              	String msg2  = "LinearLayout: " + wp + "x" + hp + " px" + LF;  
             	msg2 += "LinearLayout: " + wd + "x" + hd + " dp" + LF;  
              	mTextViewInfo2.setText( msg2 );      
			}
        });

        // 表示する
        String msg1 = "";
  		msg1 += "display: " + display.getWidth() + "x" +  display.getHeight() + LF;  
  		msg1 += "pixels: " + metrics.widthPixels + "x" + metrics.heightPixels + LF;  
  		msg1 += "dpi: " + metrics.xdpi + "x" + metrics.ydpi + LF;  
  		msg1 += "density: " + metrics.density + LF;  
  		msg1 += "densityDpi: " + metrics.densityDpi + LF;  
  		msg1 += "scaledDensity: " + metrics.scaledDensity + LF;  

         mTextViewInfo1.setText( msg1 );       
    }     

}